/*
This is the place to assemble the top-level choices available in the GUI.
A "project" is a list of model cases. Use pl.addProject() to add another entry to the projects toolbar at the very top of the window.
A "model" in this context is an Environment object with a linked Ecosystem object. Use addModel() to add an entry to the second toolbar.
A "view" is a display mode for a particular model. These will show up in a toolbar at the bottom if a model has more than one of them. Use "addView".
Note also the makeDefault() methods.

Right now, the sequence that these things show up in the toolbars can't be controlled. This is a limitation of the HashMap implementation, which ought
to change in the future.

Note that defaults and ranges for free parameters (controlled by sliders) are set within the Ecosystem and Environment objects, but initial conditions
are set here. It doesn't have to be this way: all of the configuration of a given model case, including its linked Views, could be moved into a custom
class that extends Environment.

Note also that all the configuration done here is run _before_ the projects, models, and views get linked to the GUI, and thus at this point they don't
have access to the screen layout, colors, fonts, etc. Any graphical customization of a View has to be done within the View.define() method.
*/


ProjectList assembleMasterProjectList() {
  ProjectList pl = new ProjectList();
  Project p;
  Environment env;
  
    
  // ASTroCAT  -------------------------------------
  p = pl.addProject("ASTroCAT");
  pl.makeDefault(p);

  int[] NP = new int[] {4, 8, 16, 24, 40};
  for (int i=0; i<NP.length; i++) {
    env = new ASTroCAT_Chemostat(NP[i]);
    env.shortname = "ASTroCAT (n=" + NP[i] + ")";
    env.name = "Allometric/Stochastic Trophic Complexity\nAnalysis Tool (ASTroCAT)";
    env.addView(new ASTroCAT_NetworkView(env.eco));
    p.addModel(env);
    p.makeDefault(env);
  }
  
  env = new ASTroCAT_Chemostat(16,6);
  env.shortname = "ASTroCAT_clonal";
  env.name = "ASTroCAT clonal";
  env.addView(new ASTroCAT_NetworkView(env.eco));
  p.addModel(env);
  p.makeDefault(env);

  
  // simple NPZ models --------------------------------
  p = pl.addProject("simple NPZ models"); // examples included with ASTroCAT 1.6
  
  env = new Environment(new SimpleNPZ());
  env.shortname = "NPZ";
  env.name = "nutrients + phytoplankton + zooplankton";
  env.commentary = "An example of a traditional closed, three-box NPZ model.";
  env.addView(new SimpleNPZ_NetworkView(env.eco));
  env.getVar("N").setInitial(10);
  env.getVar("P").setInitial(0.1);
  env.getVar("Z").setInitial(0.1);
  p.addModel(env);

  env = new Environment(new SimpleNPZD());
  env.shortname = "NPZD";
  env.name = "nutrients + phytoplankton + zooplankton + detritus";
  env.commentary = "An example of a traditional four-box NPZD model.";
  env.addView(new SimpleNPZD_NetworkView(env.eco));
  env.getVar("N").setInitial(10);
  env.getVar("P").setInitial(0.1);
  env.getVar("Z").setInitial(0.1);
  p.addModel(env);
  p.makeDefault(env);
  
  return pl;
}




// ---------------------------------------------------------------------------------------------


class ProjectList extends HashMap {

   Project currentProject;
   
   ProjectList() {}
   
   Project addProject(String name) {
     Project p = new Project(name);
     put(name, p);
     return p;
   }
   
   Project addProject(Project p) {
     put(p.shortname, p);
     return p;
   }
   
   void makeDefault(Project p) {
     currentProject = p;
   }
   
}





class Project extends HashMap {

  String shortname;
  Environment currentModel = null;
  Toolbar modelsToolbar = null;
  
  Project(String shortname) {
    this.shortname = shortname;
    currentModel = null;
  }
  
  Environment addModel(Environment env) {
    put(env.shortname, env);
    if (currentModel == null) currentModel = env;
    return env;
  }
  
  void makeDefault(Environment env) {
    currentModel = env;
  }
  
}
